//
//  GTNNormalTableViewCell.m
//  iOSApp01
//
//  Created by yxh on 2020/4/28.
//  Copyright © 2020 yxh. All rights reserved.
//

#import "GTNNormalTableViewCell.h"

@interface GTNNormalTableViewCell()

@property(nonatomic,strong,readwrite) UILabel *titleL;
@property(nonatomic,strong,readwrite) UILabel *sourceL;
@property(nonatomic,strong,readwrite) UILabel *commentL;
@property(nonatomic,strong,readwrite) UILabel *timeL;
@property(nonatomic,strong,readwrite) UIImageView *imageV;
@property(nonatomic,strong,readwrite) UIButton *deleteB;

@end


@implementation GTNNormalTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier{
    self = [super  initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        [self.contentView addSubview:({
            self.titleL = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, 300, 50 )];
            self.titleL.font = [UIFont systemFontOfSize:16];
            self.titleL.textColor = [UIColor blackColor];
            //            self.titleL.backgroundColor = [UIColor redColor];
            self.titleL;
        })];
        
        [self.contentView addSubview:({
            self.sourceL = [[UILabel alloc] initWithFrame:CGRectMake(30, 60, 50, 20 )];
            self.sourceL.font = [UIFont systemFontOfSize:12];
            self.sourceL.textColor = [UIColor grayColor];
            //            self.sourceL.backgroundColor = [UIColor blackColor];
            self.sourceL;
        })];
        
        [self.contentView addSubview:({
            self.commentL = [[UILabel alloc] initWithFrame:CGRectMake(100, 60, 50, 20 )];
            self.commentL.font = [UIFont systemFontOfSize:12];
            self.commentL.textColor = [UIColor grayColor];
            //            self.commentL.backgroundColor = [UIColor cyanColor];
            self.commentL;
        })];
        
        [self.contentView addSubview:({
            self.timeL = [[UILabel alloc] initWithFrame:CGRectMake(150, 60, 50, 20 )];
            self.timeL.font = [UIFont systemFontOfSize:12];
            self.timeL.textColor = [UIColor grayColor];
            //            self.timeL.backgroundColor = [UIColor yellowColor];
            self.timeL;
        })];
        
        [self.contentView addSubview:({
            self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(320, 10, 70, 70 )];
            self.imageV.backgroundColor = [UIColor redColor];
            self.imageV;
        })];
        
        [self.contentView addSubview:({
            self.deleteB = [[UIButton alloc] initWithFrame:CGRectMake(290, 60, 20, 20 )];
            [self.deleteB setTitle:@"X" forState:UIControlStateNormal];
            [self.deleteB addTarget:self action:@selector(deleteButtonClick) forControlEvents:UIControlEventTouchUpInside];
            self.deleteB.backgroundColor = [UIColor blueColor];
            self.deleteB;
        })];
        
        
        
    }
    return self;
}

- (void) layoutTableViewCell{
    self.titleL.text = @"标题";
    
    self.sourceL.text = @"iOS快速开发";
    [self.sourceL sizeToFit];
    
    self.commentL.text = @"20K+评论";
    [self.commentL sizeToFit];
    self.commentL.frame = CGRectMake(self.sourceL.frame.origin.x + self.sourceL.frame.size.width +15, self.commentL.frame.origin.y, self.commentL.frame.size.width, self.commentL.frame.size.height);
    
    self.timeL.text = @"三分钟更新";
    [self.timeL sizeToFit];
    self.timeL.frame = CGRectMake(self.commentL.frame.origin.x + self.commentL.frame.size.width +15, self.timeL.frame.origin.y, self.timeL.frame.size.width, self.timeL.frame.size.height);
}

- (void) deleteButtonClick{
    if(self.delegate && [self.delegate respondsToSelector:@selector(tableViewCell:clickDeleteButton:)]){
        [self.delegate tableViewCell:self clickDeleteButton:self.deleteB];
    }
}
@end
